package com.qpx.springbootdemo1.filter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;


@Component
@WebFilter(urlPatterns = "/**",filterName = "myFilter")
@Order(100)
public class MyFilter implements Filter {


    Logger logger = LoggerFactory.getLogger(this.getClass());

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        logger.info("--------myFilter-----------");
       HttpServletRequest request  =  (HttpServletRequest)servletRequest;
        String token = request.getParameter("token");
        logger.info("----{}---myFilter",token);

        filterChain.doFilter(servletRequest,servletResponse);

    }
}
